/**
 * 游戏的基类
 */
class baseGame extends eui.Component {
	/** 需要的资源组 */
	protected RES:string;
	/** 显示游戏容器 */
	protected box:egret.DisplayObjectContainer;
	/** 游戏ext参数 */
	public ext:string;

	public constructor() {
		super();
		this.width = 540;
		this.height = 960;
		this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
	}
	/** 游戏被添加到场景上的时候 */
	public onAddToStage(event:egret.Event):void{
		this.onStageSize(null);
		this.removeEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
		this.stage.addEventListener(egret.Event.RESIZE, this.onStageSize, this);
		this.RES && RES.loadGroup(this.RES);
	}
	/** 场景大小修改的时候 */
	public onStageSize(e:egret.Event):void{
		console.log("onStageSize", this.stage.stageHeight, this.stage.stageWidth);
		if(window.innerWidth > window.innerHeight) this.stage.scaleMode = egret.StageScaleMode.SHOW_ALL;
		else this.stage.scaleMode = egret.StageScaleMode.EXACT_FIT;
		//else this.stage.scaleMode = egret.StageScaleMode.FIXED_HEIGHT;
		this.scaleX = this.gScaleX();
		this.scaleY = this.gScaleY();
	}
	/** 游戏的宽度 */
	public gScaleX():number{
		return this.stage.stageWidth / this.width;
	}
	/** 游戏的高度 */
	public gScaleY():number{
		return this.stage.stageHeight / this.height;
	}
	/** 游戏显示 */
	public gameShow():void{
		this.onStageSize(null);
	}
}